package com.ssy.lingxi.member.merchant.entity;

import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToFileListConverter;
import com.ssy.lingxi.member.merchant.model.bo.FileBO;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 会员考察
 * @author yzc
 * @version 2.0.0
 * @date 2021/5/17
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_inspect", indexes = {@Index(name = "ms_mc_member_inspect_create_time_idx", columnList = "createTime"), @Index(name = "ms_mc_member_inspect_member_role_id_idx", columnList = "memberId, roleId"), @Index(name = "ms_mc_member_inspect_subject_idx", columnList = "subject"), @Index(name = "ms_mc_member_inspect_type_idx", columnList = "inspectType")})
public class MemberInspectDO implements Serializable {
    private static final long serialVersionUID = 5155429409039781259L;

    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_inspect_seq")
    @SequenceGenerator(sequenceName = "ms_mc_member_inspect_seq", name = "member_inspect_seq", allocationSize = 1)
    private Long id;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 考察日期
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime inspectTime;

    /**
     * 创建来源，定义在MemberInspectSourceEnum中，0-通过新增接口创建，1-通过会员审核流程创建
     */
    @Column
    private Integer source;

    /**
     * 会员id
     */
    @Column
    private Long memberId;

    /**
     * 角色id
     */
    @Column
    private Long roleId;

    /**
     * 多对一单向关联下级会员
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "sub_member_id", referencedColumnName = "id")
    private MemberDO subMember;

    /**
     * 下级角色id
     */
    @Column
    private Long subRoleId;

    /**
     * 考察主题
     */
    @Column(columnDefinition = "varchar(50)")
    private String subject;

    /**
     * 考察类型
     */
    @Column
    private Integer inspectType;

    /**
     * 多对一单向关联下级会员用户(考察人员)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private MemberUserDO byUser;

    /**
     * 考察人员名称, 当byUser为null的时候,该字段有值,即byUser是数据库的数据, 该字段为用户编辑的数据
     */
    @Column
    private String byUserEditName;

    /**
     * 考察原因
     */
    @Column(columnDefinition = "varchar(150)")
    private String reason;

    /**
     * 考察附件
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> attachments;

    /**
     * 考察评分
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal score;

    /**
     * 考察结果
     */
    @Column(columnDefinition = "varchar(100)")
    private String result;

    /**
     * 考察报告
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> reports;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getInspectTime() {
        return inspectTime;
    }

    public void setInspectTime(LocalDateTime inspectTime) {
        this.inspectTime = inspectTime;
    }

    public Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public MemberDO getSubMember() {
        return subMember;
    }

    public void setSubMember(MemberDO subMember) {
        this.subMember = subMember;
    }

    public Long getSubRoleId() {
        return subRoleId;
    }

    public void setSubRoleId(Long subRoleId) {
        this.subRoleId = subRoleId;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Integer getInspectType() {
        return inspectType;
    }

    public void setInspectType(Integer inspectType) {
        this.inspectType = inspectType;
    }

    public MemberUserDO getByUser() {
        return byUser;
    }

    public void setByUser(MemberUserDO byUser) {
        this.byUser = byUser;
    }

    public String getByUserEditName() {
        return byUserEditName;
    }

    public void setByUserEditName(String byUserEditName) {
        this.byUserEditName = byUserEditName;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public List<FileBO> getAttachments() {
        return attachments;
    }

    public void setAttachments(List<FileBO> attachments) {
        this.attachments = attachments;
    }

    public BigDecimal getScore() {
        return score;
    }

    public void setScore(BigDecimal score) {
        this.score = score;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public List<FileBO> getReports() {
        return reports;
    }

    public void setReports(List<FileBO> reports) {
        this.reports = reports;
    }
}
